package org.parademo.model;

import java.util.ArrayList;
import java.util.Random;

/**
 * @author Ajit Skanda
 * @version 1.0
 */
public class CommunityEntity extends Entity {

    private String name;
    private CommunityEntity parent;
    private RegionEntity region;
	private ArrayList<Long> members = new ArrayList<Long>();

	public CommunityEntity(String pName, CommunityEntity pParent, RegionEntity pRegion) {
		id = new Random().nextLong();
		name = pName;
		parent = pParent;
		region = pRegion;
	}

    public String getName() {
        return name;
    }

    public void setName(String pName) {
	    String oldName = name;
		name = pName;
	    pcs.firePropertyChange("name", oldName, pName);
    }

    public CommunityEntity getParent() {
        return parent;
    }

    public void setParent(CommunityEntity pParent) {
	    CommunityEntity oldParent = parent;
        parent = pParent;
	    pcs.firePropertyChange("parent", oldParent, pParent);
    }

    public RegionEntity getRegion() {
        return region;
    }

    public void setRegion(RegionEntity pRegion) {
        RegionEntity oldRegion = region;
	    this.region = pRegion;
	    pcs.firePropertyChange("region", oldRegion, pRegion);
    }

	public ArrayList<Long> getMembers() {
		return members;
	}

	public void setMembers(ArrayList<Long> pMembers) {
		ArrayList<Long> oldMembers = members;
		members = pMembers;
		pcs.firePropertyChange("members", oldMembers, pMembers);
	}

}
